Replace white space between ""
Replace white space between ""
am 31.05.2010 19:53:58 von stephanelegault
--===============0672818000==
Content-Type: multipart/alternative; boundary="0-1991031410-1275328438=:19803"
--0-1991031410-1275328438=:19803
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Hi,
I need to replace white space between delemiter "". After looking =
for do this I need to tell I did not find the solution!=0A$test=3D'test "RO=
YALE JEWELLER"@omr12.test.com test';
And I would like have this in $te=
st3 (look the space between royale and jeweller is gone):=0Atest "ROYALEJEW=
ELLER"@omr12.networksolutionsemail.com test
--0-1991031410-1275328438=:19803
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
ad>
font-size:12pt">Hi,
=0A
=0AI need to replace=
white space between delemiter "". After looking for do this I need to tell=
I did not find the solution!
=0A$test=3D'test
"ROYALE JEWELLER"@omr12.networksolutionsemail.com'>"ROYALE JEWELLER"@omr12.=
test.com test';
=0A
=0AAnd I would like have =
this in $test3 (look the space between royale and jeweller is gone):
=
=0Atest
..com'>"ROYALEJEWELLER"@omr12.networksolutionsemail.com test
=
--0-1991031410-1275328438=:19803--
--===============0672818000==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============0672818000==--
Re: Replace white space between ""
am 31.05.2010 21:36:19 von Serguei Trouchelle
Stephane Legault wrote:
> I need to replace white space between delemiter "". After looking for do
> this I need to tell I did not find the solution!
> $test='test "ROYALE JEWELLER"@omr12.test.com
> JEWELLER"@omr12.networksolutionsemail.com> test';
> And I would like have this in $test3 (look the space between royale and
> jeweller is gone):
> test "ROYALEJEWELLER"@omr12.networksolutionsemail.com test
$test =~ s/(".*?")/ $_ = $1; s!\s!!g; $_; /gex;
--
Serguei Trouchelle
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://list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N0CkFjdGl2
ZVBlcmxAbGlzdHNlcnYuQWN0aXZlU3RhdGUuY29tClRvIHVuc3Vic2NyaWJl OiBodHRwOi8vbGlz
dHNlcnYuQWN0aXZlU3RhdGUuY29tL21haWxtYW4vbXlzdWJz
Re: Replace white space between ""
am 01.06.2010 00:16:52 von Serguei Trouchelle
Angelos Karageorgiou wrote:
>>> I need to replace white space between delemiter "". After looking for do
>>> this I need to tell I did not find the solution!
>>> $test='test "ROYALE JEWELLER"@omr12.test.com
>>> JEWELLER"@omr12.networksolutionsemail.com> test';
>>> And I would like have this in $test3 (look the space between royale and
>>> jeweller is gone):
>>> test "ROYALEJEWELLER"@omr12.networksolutionsemail.com test
>> $test =~ s/(".*?")/ $_ = $1; s!\s!!g; $_; /gex;
> Duh , please elaborate , it is edifying :-)
/e switch in s/// commands to treat replacement part as Perl expression. So, any Perl code can be there, and returning
value will be used to replace matching pattern. So, technically, it's just nested s/// , but you can do pretty anything.
For example, s/(\d+)/sqrt($1)/gex changes any number to its square root.
perldoc perlop has some examples of how s/// can be used.
--
Serguei Trouchelle
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Replace white space between ""
am 01.06.2010 12:31:28 von Brian Raven
Serguei Trouchelle <> wrote:
> Stephane Legault wrote:
>
>> I need to replace white space between delemiter "". After looking for
>> do this I need to tell I did not find the solution!
>> $test='test "ROYALE JEWELLER"@omr12.test.com
>> JEWELLER"@omr12.networksolutionsemail.com> test'; And I would like
>> have this in $test3 (look the space between royale and jeweller is
>> gone): test "ROYALEJEWELLER"@omr12.networksolutionsemail.com test
>
> $test =~ s/(".*?")/ $_ = $1; s!\s!!g; $_; /gex;
A possible alternative for matching the quoted substring is to use
Regexp::Common. It may be more verbose, but it has the advantage of
handling embedded quotes, as long as they are escaped. For example:
--------------------------------------------
use strict;
use warnings;
use Regexp::Common;
while () {
chomp;
print "Before: '$_'\n";
s/$RE{quoted}{-keep}/$_ = $1; s!\s!!g; $_/egx;
print "After: '$_'\n";
}
__DATA__
test "ROYALE JEWELLER"@omr12.test.com test
test "ROYALE \"JELLY\""@omr12.test.com test
--------------------------------------------
See 'perldoc Regexp::Common' for more useful REs. The code is quite
interesting too.
--
Brian Raven
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Replace white space between ""
am 01.06.2010 14:44:36 von francois.bourgneuf
=
$test=3D'test "ROYALE JEWELLER"@omr12.test.com test'; =
$test=3D~s!"(.*) (.*)"!"$1$2"!; # =
print $test
>> test "ROYALEJEWELLER"@omr12.test.com test
If you want to remove all the whitespaces that may be between ""
$test=3D'test "ROYALE JE WEL LER "@omr12.test.com test';
1 while $test=3D~s!"(.*) (.*)"!"$1$2"!g;
print $test
>> test "ROYALEJEWELLER"@omr12.test.com test
bour9
-----Message d'origine-----
De : activeperl-bounces@listserv.ActiveState.com [mailto:activeperl-bounces=
@listserv.ActiveState.com] De la part de Brian Raven
Envoy=E9 : mardi 1 juin 2010 12:31
=C0 : activeperl@listserv.activestate.com
Objet : RE: Replace white space between ""
Serguei Trouchelle <> wrote:
> Stephane Legault wrote:
> =
>> I need to replace white space between delemiter "". After looking for =
>> do this I need to tell I did not find the solution!
>> $test=3D'test "ROYALE JEWELLER"@omr12.test.com
>> JEWELLER"@omr12.networksolutionsemail.com> test'; And I would like =
>> have this in $test3 (look the space between royale and jeweller is
>> gone): test "ROYALEJEWELLER"@omr12.networksolutionsemail.com test
> =
> $test =3D~ s/(".*?")/ $_ =3D $1; s!\s!!g; $_; /gex;
A possible alternative for matching the quoted substring is to use Regexp::=
Common. It may be more verbose, but it has the advantage of handling embedd=
ed quotes, as long as they are escaped. For example:
--------------------------------------------
use strict;
use warnings;
use Regexp::Common;
while () {
chomp;
print "Before: '$_'\n";
s/$RE{quoted}{-keep}/$_ =3D $1; s!\s!!g; $_/egx;
print "After: '$_'\n";
}
__DATA__
test "ROYALE JEWELLER"@omr12.test.com test test "ROYALE \"JELLY\""@omr12.te=
st.com test
--------------------------------------------
See 'perldoc Regexp::Common' for more useful REs. The code is quite interes=
ting too.
--
Brian Raven
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs